﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.storage.ui {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import Events.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.util.*;
    import Display.*;
    import Display.MarketUI.*;
    import Modules.storage.*;
    import Display.aswingui.*;

    public class StorageView extends Catalog {

        public static const SCROLL_HEIGHT:int = 550;

        public static var assetDict:Dictionary;

        protected var m_storageItem:ItemStorage;

        public function StorageView(_arg1:ItemStorage, _arg2:String=null, _arg3:String=""){
            var _local4:StorageCatalogUI = new StorageCatalogUI();
            this.m_storageItem = _arg1;
            super("", _local4, _arg3, false, "", false);
        }
        public static function getStorageCatalogType(_arg1:StorageType, _arg2:String):String{
            return (((_arg1.type + "|") + _arg2));
        }
        public static function getStorageTypeFromCatalogType(_arg1:String):StorageType{
            return (StorageType.createEnum(_arg1.split("|", 2)[0]));
        }
        public static function getStorageKeyFromCatalogType(_arg1:String):String{
            return (_arg1.split("|", 2)[1]);
        }

        public function get storageItem():ItemStorage{
            return (this.m_storageItem);
        }
        public function get storageType():StorageType{
            return (this.m_storageItem.getStorageType());
        }
        public function get storageKey():String{
            return (this.m_storageItem.getStorageKey());
        }
        override protected function loadAssets():void{
            m_content = m_ui;
            Global.delayedAssets.get(DelayedAssetLoader.INVENTORY_ASSETS, this.makeAssets);
            var _local1:Sprite = new Sprite();
            this.addChild(_local1);
            var _local2:JWindow = new JWindow(_local1);
            _local2.setContentPane(m_ui);
            ASwingHelper.prepare(_local2);
            _local2.show();
        }
        override protected function makeAssets(_arg1:DisplayObject, _arg2:String):void{
            m_comObject = _arg1;
            this.setChrome(null);
        }
        override protected function getScrollHeight():int{
            return (SCROLL_HEIGHT);
        }
        public function refresh():void{
            asset.switchType(getStorageCatalogType(this.storageType, this.storageKey));
        }
        override public function centerPopup():void{
            var _local1:Rectangle;
            var _local2:Point;
            var _local3:Number;
            if (parent){
                _local1 = Global.hud.getRect(parent);
                _local2 = new Point(((Global.stage.stageWidth - m_content.width) / 2), Global.stage.stageHeight);
                _local3 = Global.hud.localToGlobal(new Point(Global.hud.x, Global.hud.y)).x;
                this.x = (_local2.x - _local3);
                this.y = (_local1.y + _local2.y);
            };
        }
        override protected function setChrome(_arg1:Event):void{
            StorageView.assetDict = new Dictionary(true);
            StorageView.assetDict["btn_prev_up"] = m_comObject.btn_prev_up;
            StorageView.assetDict["btn_prev_over"] = m_comObject.btn_prev_over;
            StorageView.assetDict["btn_prev_down"] = m_comObject.btn_prev_down;
            StorageView.assetDict["btn_next_up"] = m_comObject.btn_next_up;
            StorageView.assetDict["btn_next_over"] = m_comObject.btn_next_over;
            StorageView.assetDict["btn_next_down"] = m_comObject.btn_next_down;
            StorageView.assetDict["btn_close_big_up"] = m_comObject.btn_close_big_up;
            StorageView.assetDict["btn_close_big_over"] = m_comObject.btn_close_big_over;
            StorageView.assetDict["btn_close_big_down"] = m_comObject.btn_close_big_down;
            StorageView.assetDict["btn_close_small_up"] = m_comObject.btn_close_small_up;
            StorageView.assetDict["btn_close_small_over"] = m_comObject.btn_close_small_over;
            StorageView.assetDict["btn_close_small_down"] = m_comObject.btn_close_small_down;
            StorageView.assetDict["verticalRule"] = m_comObject.verticalRule;
            StorageView.assetDict["collectionFlyout"] = m_comObject.collectionFlyout;
            StorageView.assetDict["collections_inventory_item"] = m_comObject.inventoryCollectionsItem;
            StorageView.assetDict["collections_item_empty"] = m_comObject.collectionsItemEmpty;
            StorageView.assetDict["wishlistItem"] = m_comObject.wishlistItem;
            StorageView.assetDict["countBG"] = m_comObject.countBG;
            StorageView.assetDict["countMaxBG"] = m_comObject.countMaxBG;
            StorageView.assetDict["gift_down"] = m_comObject.btn_gift_down;
            StorageView.assetDict["gift_over"] = m_comObject.btn_gift_over;
            StorageView.assetDict["gift_up"] = m_comObject.btn_gift_up;
            StorageView.assetDict["wishlist_icon"] = m_comObject.wishlistIcon;
            StorageView.assetDict["inventory_card"] = m_comObject.inventoryCard;
            StorageView.assetDict["inventory_card_locked"] = m_comObject.inventoryCardLocked;
            StorageView.assetDict["add_to_wishlist"] = m_comObject.addtoWishList;
            StorageView.assetDict["inventory_card_locked"] = m_comObject.inventoryCardLocked;
            StorageView.assetDict["collectionsCard_ready"] = m_comObject.collectionsCardReady;
            var _local2:String = getStorageCatalogType(this.storageType, this.storageKey);
            var _local3 = "";
            asset.init(_local2, this, _local3, false, "");
            m_cursorId = UI.setCursor(null);
            this.mouseEnabled = (this.mouseChildren = true);
        }
        override public function canBuy(_arg1:Item):Boolean{
            return (true);
        }
        override public function onBuy(_arg1:Item, _arg2:Object=null):void{
            if (!_arg1){
                return;
            };
            var _local3:MarketEvent = MarketEvent.build(MarketEvent.MARKET_BUY, _arg1, MarketEvent.SOURCE_STORAGE);
            if (_local3){
                doItemActions(_arg1, _arg2);
                dispatchEvent(_local3);
            };
            onCloseClick(true);
        }

    }
}//package Modules.storage.ui 
